<?php
include("../conf.php");
class Query
{
	public $select;
	public $insert;
	public $update;
	public $delete;
	public $from;
	public $where;
	public $orderby;
	public $havingby;
	
}
class SqlHelper
{
	private $conn;	
	public function __construct()
	{			
		$this->conn = mysql_connect(Config::$server, Config::$user, Config::$psw);		
		mysql_select_db(Config::$db, $this->conn);	
	}
	
	public function __destruct()
	{		
		mysql_close($this->conn);
	} 
	
	select * 
	from 
	where
	orderby
	having
	
	
	public function ExecuteNonQuery($p){
	
		mysql_query($q);		
	}
	
	public function ExecuteQuery($para){
		$q="";
		$a = array(" select ", " from ", " where ", " order by ", " having by ");
		$i=-1;
		$l=count($a);
		while(++$i < $l){
			$q=$q . $a[i] . $para[i];			
		}	
		$result = mysql_query($q, $this->conn);
		if (!$result) {			
			return "";
		}
		
		$i=0;			
		while ($row = mysql_fetch_assoc($result)) {
			$j=0;
			while($j < count($para))
			{
				$t[$i][$j]= $row[$paras[$j]];					
				$j++;
			}
			$i++;
			
			
		}
		mysql_free_result($result);
		if($i==0)
		return "";
		return json_encode($t);
	}
}
?>